#include "StdAfx.h"
#include "SolarWing.h"
#include "SolarWingDisObj.h"


CSolarWing::CSolarWing(void):CActiveComponentObj()
{
	m_ActiveComponentType=ACTIVE_COMPONENT_SOLAR_WING;
	m_strPathName=_T("");
}

CSolarWing::CSolarWing( CEntityObj* pParentEnt ):CActiveComponentObj(pParentEnt)
{
	m_ActiveComponentType=ACTIVE_COMPONENT_SOLAR_WING;
	m_strPathName=_T("");
}

CSolarWing::CSolarWing( CSolarWing* pChartObj ):CActiveComponentObj(pChartObj)
{
	m_ActiveComponentType=pChartObj->GetActiveComponentType();
	m_strPathName=pChartObj->GetPathName();
}


CSolarWing::~CSolarWing(void)
{
}

void CSolarWing::Serialize( CArchive & ar )
{
	if (ar.IsStoring())
	{		
		CObj::WriteString(ar,m_strPathName);		
	} 
	else
	{
		CObj::ReadString(ar,m_strPathName);
	}
	CActiveComponentObj::Serialize(ar);
}

CDisplayObj * CSolarWing::CreateDisplayObj( long lLayerId )
{
	CSolarWingDisObj *pChartDisObj = new CSolarWingDisObj(this);
	pChartDisObj->SetLayerId(lLayerId);

	list<CShape *>::iterator it_shape;
	for (it_shape=m_ShapeList.begin(); it_shape!=m_ShapeList.end(); it_shape++)
	{
		(*it_shape)->CreateDisplayObj(lLayerId);
	}

	return pChartDisObj;
}


bool CSolarWing::ModifyLight()
{	
	DriveParamData tempdata=GetDriveParamData();
	bool IsLight=(bool)tempdata.dblValue;

	if (IsLight)
	{
		CSolarWing* pSolar = dynamic_cast<CSolarWing*>(this);

		int n=m_strPathName.ReverseFind(_T('\\'));
		m_strPathName=m_strPathName.Left(n)+_T("\\solararray_top_light.jpg");
	}
	else
	{
		int n=m_strPathName.ReverseFind(_T('\\'));
		m_strPathName=m_strPathName.Left(n)+_T("\\solararray_top.jpg");
	}


	return IsLight;
}
